package com.young.quartz.scheduler;


import com.young.quartz.domain.entity.QuartzLogEntity;
import com.young.quartz.mapper.QuartzLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;


@Slf4j
public class TestJob implements BaseJob {
    @Autowired
    private QuartzLogMapper quartzLogMapper;


    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
          log.info("===================testjob execute==============");
        } catch (Exception e) {
            quartzLogMapper.insert(
                    QuartzLogEntity.builder()
                            .jobClassName(this.getClass().getName())
                            .description("测试定时任务")
                            .status("1")
                            .params(null)
                            .mark("")
                            .createTime(new Date())
                            .build());
        }
    }


    @Override
    public void execute(QuartzLogEntity quartzLogEntity) {

    }
}
